<%--
  Created by IntelliJ IDEA.
  User: teacher
  Date: 2022/4/12
  Time: 17:07
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>用户登录</title>
    <script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-3.4.1.min.js"></script>
    <script>
        $(function(){
           $("#codeImage").click(function(){
               // 想要图片发生变化,那么必须使得更改的src属性与原有的属性值不一致
               // 但是绘制验证码的url是固定的
               // 因此,可以从参数入手考虑,给参数不影响绘制的效果
               // 要求每一次url地址均不一样
               // 即使得参数值永不重复
               // 时间永远不会重复,可以考虑使用毫秒数来实现
              $(this).attr("src","<%=request.getContextPath()%>/show.code?id="+new Date().getTime());
           });
        });
    </script>
</head>
<body>
<h1>用户登录</h1>
<a href="<%=request.getContextPath()%>/jsp/register.jsp">返回注册</a>
<hr/>
<%--<form action="<%=request.getContextPath()%>/login" method="post">--%>
<form action="<%=request.getContextPath()%>/login.user" method="post">
    用户名:<input type="text" name="username"/><br/>
    密&nbsp;&nbsp;&nbsp;码:<input type="password" name="password"/><br/>
    记住密码:
    <input type="radio" name="maxAge" value="86400" checked/>一天
    <input type="radio" name="maxAge" value="604800"/>一周
    <input type="radio" name="maxAge" value="31536000"/>一年<br/>
    验证码:<input type="text" name="code"/>
    <a href="javascript:;"><img id="codeImage" src="<%=request.getContextPath()%>/show.code" alt="验证码加载失败"/></a>
    <br/>
    <input type="submit" value="登录">
    <span style="color:red;">
        <%
            String loginMsg = (String) request.getAttribute("loginMsg");
            if(loginMsg != null){
                out.print(loginMsg);
            }
        %>
    </span>
</form>
</body>
</html>
